import sys,os
sys.path.append(os.path.join(os.getcwd()))
# print(sys.path)
from tool.auth.cookieCheck import cookie_jwt_required
from tool.config import config
from flask import Flask, render_template
# 暂时注释掉audioBot.waitSpeak的导入，因为它有复杂的依赖问题
# from audioBot.waitSpeak import wait_speak
import os
from views.auth.auth import auth_bp
from views.filesys.filesys import fs_bp
from views.settings.settings import settings_bp
from views.llm_serve.view import llm_serve_bp

config = config.get_config("config.toml")

app = Flask(__name__)
app.register_blueprint(auth_bp)
app.register_blueprint(fs_bp)
app.register_blueprint(settings_bp)
app.register_blueprint(llm_serve_bp)
# app.config["JWT_SECRET_KEY"] = config["FILE_SYSTEM"]["JWT_SECRET_KEY"]  # 应使用更安全的密钥

os.makedirs(config["FILE_SYSTEM"]["UPLOAD_FOLDER"], exist_ok=True)

@app.route("/", methods=["GET"])
def index():
    return render_template("index.html")

@app.route("/ai4stu", methods=["GET"])
def ai4stu():
    return render_template("ai4stu.html")


if __name__ == "__main__":
    # sqlOp.init_db()
    # wait_speak()  # 启动录音监听
    # app.run(debug=True)
    app.run()